home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / util / snap_1_4 / part02 < prev    next >
Encoding:
Internet Message Format  |  1990-02-11  |  49.3 KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i068: Snap 1.4 - cut, store, and paste between windows, Part02/04
  5. Message-ID: <11376@xanth.cs.odu.edu>
  6. Date: 11 Feb 90 22:50:04 GMT
  7. Sender: tadguy@cs.odu.edu
  8. Reply-To: micke@slaka.sirius.se (Mikael Karlsson)
  9. Lines: 1766
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11. X-Mail-Submissions-To: Amiga@cs.odu.edu
  12. X-Post-Discussions-To: comp.sys.amiga
  13.  
  14. Submitted-by: micke@slaka.sirius.se (Mikael Karlsson)
  15. Posting-number: Volume 90, Issue 068
  16. Archive-name: util/snap-1.4/part02
  17.  
  18. #!/bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 2 (of 4)."
  25. # Contents:  source/ikm.c source/settings.c source/windows.c
  26. #   startsnap.rexx
  27. # Wrapped by tadguy@xanth on Sun Feb 11 17:48:45 1990
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'source/ikm.c' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'source/ikm.c'\"
  31. else
  32. echo shar: Extracting \"'source/ikm.c'\" \(9076 characters\)
  33. sed "s/^X//" >'source/ikm.c' <<'END_OF_FILE'
  34. X/* ikm.c -- invert keymaps      */
  35. X
  36. X/** NOTICE:
  37. X * The contents of this file are copyright 1987, Jim Mackraz.  All rights
  38. X * reserved.  No use of the contents of this file or the compilation
  39. X * of them may be used apart from the entire Commodities Exchange
  40. X * without written permission.
  41. X */
  42. X
  43. X#define CONTROLBITS     ( (1 << 5) | (1 << 6) )
  44. X
  45. X/* return >= 0 if ok (no error checking now)    */
  46. XULONG InvertKeyMap(ansicode, ie, km)
  47. XULONG ansicode;
  48. Xregister struct InputEvent *ie;
  49. Xstruct KeyMap *km;
  50. X{
  51. X    ULONG   kindex;
  52. X    UBYTE   code = 0;
  53. X    extern struct KeyMap keymap;
  54. X
  55. X    if (km == NULL) {
  56. X        km = &keymap;
  57. X    }
  58. X
  59. X    ie->ie_Class = IECLASS_RAWKEY;
  60. X    ie->ie_EventAddress = 0;
  61. X
  62. X    /* check for codes in (default) high map first  */
  63. X    switch(ansicode)
  64. X    {
  65. X        case ' ':
  66. X            code = 0x40;        /* space            */
  67. X            break;
  68. X        case 0x08:              /* backspace    */
  69. X            code = 0x41;
  70. X            break;
  71. X        case '\t':              /* tab                  */
  72. X            code = 0x42;
  73. X            break;
  74. X        case 0x0D:              /* return               */
  75. X            code = 0x44;
  76. X            break;
  77. X        case 0x1B:              /* esc                  */
  78. X            code = 0x45;
  79. X            break;
  80. X        case 0x7F:              /* del                  */
  81. X            code = 0x46;
  82. X            break;
  83. X    }
  84. X
  85. X    if (code) {
  86. X        ie->ie_Code = code;
  87. X        ie->ie_Qualifier = 0;
  88. X        return (1);
  89. X    }
  90. X
  91. X    if (LowKeyInvert((UBYTE) ansicode, km,
  92. X            &ie->ie_Code, &ie->ie_Qualifier, &kindex) >= 0) {
  93. X        if (kindex) {   /* was dead key, need "preceding" keystroke. */
  94. X            IndexKey(kindex, km, (ULONG *)&ie->ie_EventAddress);
  95. X        }
  96. X    }
  97. X
  98. X    return (1);
  99. X}
  100. X
  101. X#define KEYMAPSIZE      64
  102. X
  103. X/* LowKeyInvert returns good code else <0 if no find
  104. X *
  105. X * regarding keymap as many-to-one mapping:
  106. X * -entries for a given key are scanned so that
  107. X *      the minimum number of qualifiers are associated
  108. X *      with the keystroke.
  109. X * -passing a character value of zero corresponds, in
  110. X *      the default keymap, to CTRL-`, which is probably a bug.
  111. X * -numerals are matched with numeric pad keystrokes (no
  112. X *      qualifiers) on standard keymap.  The way to specify
  113. X *      a key on the number row is via its shifted value;
  114. X *      specify explicitly that the qualifier is to be unshifted,
  115. X *      or a "don't care."
  116. X */
  117. XUWORD LowKeyInvert(value, km, codep, qualp, indexp)
  118. Xregister UBYTE  value;  /* translation value from low keymap    */
  119. Xstruct  KeyMap  *km;
  120. XUWORD   *codep;         /* pointers where answers are to be put */
  121. XUWORD   *qualp;
  122. XULONG   *indexp;        /* dead-key index information (put into ie?)    */
  123. X{
  124. X    register UWORD code = 0;
  125. X    register WORD type;
  126. X    register LONG *p;             /* points to four-byte lokeymap entry   */
  127. X    WORD found_it = 0;
  128. X
  129. X    *indexp = *qualp = 0;
  130. X
  131. X    p = (LONG *) km->km_LoKeyMap;
  132. X
  133. X    do  {
  134. X        /* determine type of key        */
  135. X        if ((type = km->km_LoKeyMapTypes[code] ) == KC_VANILLA) {
  136. X            found_it = checkVanilla((UBYTE *)p, value, qualp);
  137. X        } else if (type & KCF_DEAD) {
  138. X            found_it = checkDead((UBYTE **)p, value, qualp, indexp);
  139. X        }
  140. X        /**
  141. X        else if (type & KCF_STRING) {
  142. X        }
  143. X        **/
  144. X        else if (!(type & KCF_NOP)) {
  145. X            found_it = checkNormal((LONG)p, value, (UWORD)type, qualp);
  146. X        }
  147. X
  148. X        ++p;
  149. X    } while (!found_it && ++code < KEYMAPSIZE);
  150. X
  151. X    *codep = code;
  152. X    return (code);
  153. X}
  154. X
  155. X/*
  156. X * packs code|qual of previous key (should be keys) in *dead_vudup
  157. X * returns code, <0 if failure
  158. X */
  159. XVOID IndexKey(inx, km, dead_vudup)
  160. XULONG   inx;
  161. Xstruct  KeyMap  *km;
  162. XULONG   *dead_vudup;
  163. X{
  164. X    /* find keystroke which generates index */
  165. X
  166. X    register WORD code = 0;
  167. X    UWORD **p;            /* points to four-byte lokeymap entry   */
  168. X    register UWORD *deadthing;
  169. X    WORD i;
  170. X    WORD qual = 0;
  171. X    LONG vudu;
  172. X
  173. X    p = (UWORD **) km->km_LoKeyMap;
  174. X
  175. X    do {
  176. X        /* check each deadkey in the table      */
  177. X
  178. X        if (km->km_LoKeyMapTypes[code] & KCF_DEAD) {
  179. X            /* keymap entry is pointer to eight prefix:byte pairs   */
  180. X
  181. X            deadthing = *p;
  182. X            for (i = 0; i < 8; ++i, ++deadthing) {
  183. X                /* check for index prefix and correct index     */
  184. X                if (*deadthing == ((DPF_DEAD << 8) | inx)) {
  185. X                    deadQual((WORD)i, &qual);
  186. X                    goto FOUND_IT;
  187. X                }
  188. X            }
  189. X        }
  190. X        ++p;
  191. X    } while (++code < KEYMAPSIZE);
  192. X
  193. XFOUND_IT:
  194. X
  195. X    /* pack as follows: [pred(-1)|qual(-1)|pred(-2)|qual(-2)]       */
  196. X    /* for now, 2nd previous deadkey ignored                                        */
  197. X
  198. X    if (code < 0) {
  199. X        *dead_vudup = 0;
  200. X    } else {
  201. X        vudu =  code << 8;
  202. X        vudu |= (0xFF & qual);
  203. X        vudu <<= 16;
  204. X
  205. X        *dead_vudup = vudu;
  206. X    }
  207. X}
  208. X
  209. X
  210. XWORD checkNormal(four_bytesp, val, type, qualp)
  211. XLONG    four_bytesp;
  212. XUBYTE   val;
  213. XUWORD   type;
  214. XUWORD   *qualp;
  215. X{
  216. X    register UBYTE  *p = (UBYTE *) four_bytesp; /* codes held in long word  */
  217. X    register WORD    position;
  218. X
  219. X    /* start with last of four bytes, "more vanilla"        */
  220. X    p += 3;
  221. X
  222. X    for (position = 3; position >= 0; --position, --p) {
  223. X        if (*p == val) {
  224. X            switch (type) {
  225. X                case KC_NOQUAL:
  226. X                    if (position != 3) goto NOT_THIS;
  227. X                    break;
  228. X
  229. X                case KCF_SHIFT:
  230. X                    if (!(position & 2)) goto NOT_THIS;
  231. X                    if (position == 2) *qualp |= IEQUALIFIER_LSHIFT;
  232. X                    break;
  233. X
  234. X                case KCF_ALT:
  235. X                    if (!(position & 2)) goto NOT_THIS;
  236. X                    if (position == 2) *qualp |= IEQUALIFIER_LALT;
  237. X                    break;
  238. X
  239. X                case KCF_CONTROL:
  240. X                    if (!(position & 2)) goto NOT_THIS;
  241. X                    if (position == 2) *qualp |= IEQUALIFIER_CONTROL;
  242. X                    break;
  243. X
  244. X                case KCF_ALT | KCF_CONTROL:
  245. X                    if (!(position & 1)) *qualp |= IEQUALIFIER_LALT;
  246. X                    if (!(position & 2)) *qualp |= IEQUALIFIER_CONTROL;
  247. X                    break;
  248. X
  249. X                case KCF_SHIFT | KCF_CONTROL:
  250. X                    if (!(position & 1)) *qualp |= IEQUALIFIER_LSHIFT;
  251. X                    if (!(position & 2)) *qualp |= IEQUALIFIER_CONTROL;
  252. X                    break;
  253. X
  254. X                case KCF_SHIFT | KCF_ALT:
  255. X                    if (!(position & 1)) *qualp |= IEQUALIFIER_LSHIFT;
  256. X                    if (!(position & 2)) *qualp |= IEQUALIFIER_LALT;
  257. X                    break;
  258. X                default:
  259. X                    break;
  260. X            }
  261. X            return (1);
  262. X        }
  263. XNOT_THIS:       ;
  264. X    }
  265. X    return (0);
  266. X}
  267. X
  268. XWORD checkVanilla(p, val, qualp)
  269. XUBYTE   *p;                     /* note: byte pointer   */
  270. XUBYTE   val;
  271. XUWORD   *qualp;
  272. X{
  273. X    register WORD i;
  274. X
  275. X    /* only one way to match a vanilla control key  */
  276. X    if (!(val & CONTROLBITS)) {
  277. X        /* is a control code    */
  278. X
  279. X        if ((p[3] & ~CONTROLBITS) == val) {
  280. X            *qualp |= IEQUALIFIER_CONTROL;
  281. X            return (1);
  282. X        }
  283. X    } else {
  284. X        /* not a control        */
  285. X        for (i = 3; i >= 0; --i) {
  286. X            if (p[i] == val) {
  287. X                if (!(i & 1)) *qualp |= IEQUALIFIER_LSHIFT;
  288. X                if (!(i & 2)) *qualp |= IEQUALIFIER_LALT;
  289. X                return (1);
  290. X            }
  291. X        }
  292. X    }
  293. X    return (0);
  294. X}
  295. X
  296. X
  297. XWORD checkDead(keybase, val, qualp, indexp)
  298. XUBYTE   **keybase;                      /* note: byte pointer   */
  299. XUBYTE   val;
  300. XUWORD   *qualp;
  301. XULONG   *indexp;
  302. X{
  303. X    WORD i;
  304. X    WORD j;
  305. X
  306. X    register UWORD *p = (UWORD *) *keybase;
  307. X    /* need to remember keybase for offsets */
  308. X
  309. X    UBYTE *deadp;
  310. X    WORD found_it = 0;
  311. X
  312. X    /* walk through eight two-byte entries, one for each qual. combo.       */
  313. X    for (i = 0; i < 8; ++i, ++p) {
  314. X        switch (*p >> 8) {
  315. X            case DPF_DEAD:       /* dead keys do not themselves map to anything */
  316. X                break;
  317. X            case DPF_MOD:        /* dead key modifiable  */
  318. X                deadp = *keybase + (*p & 0xFF);
  319. X                /* look down the string indexed by dead-key     index */
  320. X                for (j = 0; j < 6; ++j) {
  321. X                    if (deadp[j] == val) {
  322. X                        found_it = 1;
  323. X                        *indexp = j;
  324. X                        break;
  325. X                    }
  326. X                }
  327. X                break;
  328. X            case 0:                      /* normal stroke for this key   */
  329. X                if ((*p & 0xFF) == val) {
  330. X                    found_it = 1;
  331. X            }
  332. X        }
  333. X
  334. X        if (found_it) {
  335. X            deadQual((WORD)i, qualp);
  336. X            return (1);
  337. X        }
  338. X    }
  339. X
  340. X    return (0);
  341. X}
  342. X
  343. X/* figure out qualifier from position */
  344. XWORD deadQual(wordpos, qualp)
  345. XWORD    wordpos;                /* which word in dead-key string?       */
  346. XUWORD   *qualp;
  347. X{
  348. X    if (wordpos & 1) *qualp |= IEQUALIFIER_LSHIFT;
  349. X    if (wordpos & 2) *qualp |= IEQUALIFIER_LALT;
  350. X    if (wordpos & 4) *qualp |= IEQUALIFIER_CONTROL;
  351. X    return (0);
  352. X}
  353. X
  354. X
  355. END_OF_FILE
  356. if test 9076 -ne `wc -c <'source/ikm.c'`; then
  357.     echo shar: \"'source/ikm.c'\" unpacked with wrong size!
  358. fi
  359. # end of 'source/ikm.c'
  360. fi
  361. if test -f 'source/settings.c' -a "${1}" != "-c" ; then 
  362.   echo shar: Will not clobber existing file \"'source/settings.c'\"
  363. else
  364. echo shar: Extracting \"'source/settings.c'\" \(12211 characters\)
  365. sed "s/^X//" >'source/settings.c' <<'END_OF_FILE'
  366. X#include "snap.h"
  367. X#include <stdio.h>
  368. X
  369. X#define ARGVAL() (*++(*argv) || (--argc && *++argv))
  370. X
  371. Xstruct SnapRsrc *SnapRsrc = NULL;
  372. X
  373. XSHORT isdigit(c)
  374. XREGISTER char c;
  375. X{
  376. X    return (c>='0' && c<='9');
  377. X}
  378. X
  379. X#ifdef AZTEC_C
  380. Xchar *strupr(str)
  381. Xchar *str;
  382. X{
  383. X    register char *p = str;
  384. X    register char c;
  385. X    while (c = *p) {
  386. X        if ('a' <= c && c <= 'z') {
  387. X            *p = c - ('a' - 'A');
  388. X        }
  389. X        ++p;
  390. X    }
  391. X    return str;
  392. X}
  393. X#endif AZTEC_C
  394. X
  395. XLONG dectoint(str)
  396. XREGISTER char *str;
  397. X{
  398. X    REGISTER long val = 0;
  399. X    REGISTER char c;
  400. X    while (isdigit(c = *str)) {
  401. X        val = (((val<<2)+val)<<1) + c-'0';
  402. X        str++;
  403. X    }
  404. X    return(val);
  405. X}
  406. X
  407. XLONG hextoint(str)
  408. XREGISTER char *str;
  409. X{
  410. X    REGISTER long val = 0;
  411. X    REGISTER char c;
  412. X    while (c = *str) {
  413. X        val <<= 4;
  414. X        val |= (c & 15) + (isdigit(c) ? 0 : 9);
  415. X        str++;
  416. X    }
  417. X    return(val);
  418. X}
  419. X
  420. Xmain(argc, argv)
  421. XWORD argc;
  422. Xchar *argv[];
  423. X{
  424. X    WORD usage = 0;
  425. X
  426. X    SnapRsrc = (struct SnapRsrc *)OpenResource(SNAPRSRC);
  427. X    if (!SnapRsrc) {
  428. X        puts("Snap not installed");
  429. X        exit(0);
  430. X    }
  431. X
  432. X    if (argc == 1) {
  433. X        puts("Snap settings:");
  434. X        printf("Priority:    %d\n", SnapRsrc->Priority);
  435. X        printf("Gfx Qual:    %x, ", SnapRsrc->gfxqual);
  436. X        printf("Text Qual:   %x\n", SnapRsrc->textqual);
  437. X        printf("Insert key:  %x, ", SnapRsrc->insertkey);
  438. X        printf("CW key:      %x\n", SnapRsrc->cwkey);
  439. X        printf("Prepend:     \"%s\"\n", &SnapRsrc->Prepend);
  440. X        printf("Append:      \"%s\"\n", &SnapRsrc->Append);
  441. X        printf("Xerox:       %s, ", (SnapRsrc->flags & XEROX ? "On " : "Off"));
  442. X        printf("Early patch: %s\n", (SnapRsrc->flags & EARLYPATCH ? "On " : "Off"));
  443. X        printf("Join long:   %s, ", (SnapRsrc->flags & JOINLONG ? "On " : "Off"));
  444. X        printf("Underscore:  %s\n", (SnapRsrc->flags & TRUEUNDERSCORE ? "True" : "Fake"));
  445. X        printf("Line Delay:  %ld, ", SnapRsrc->linedelay);
  446. X        printf("Char Delay:  %ld\n", SnapRsrc->chardelay);
  447. X        printf("Crawl Ptrn:  %x\n", SnapRsrc->CrawlPtrn);
  448. X        printf("Start Unit:  %d\n", SnapRsrc->StartUnit);
  449. X        printf("Frame Mask:  %x\n", SnapRsrc->FrameMask);
  450. X        printf("Gad Offset:  %d\n", SnapRsrc->GadOffset);
  451. X        printf("Cache Size:  %d\n", SnapRsrc->CacheSize);
  452. X        printf("Bad char:    %d\n", SnapRsrc->BadChar);
  453. X        exit(0);
  454. X    }
  455. X
  456. X    for (argc--, argv++; argc > 0; argc--, argv++) {
  457. X        if (**argv == '-') { /* Argument coming up */
  458. X            switch(*++(*argv)) {
  459. X                case 'p': priority: {  /* Priority */
  460. X                    if (ARGVAL()) {
  461. X                        WORD pri = dectoint(*argv);
  462. X                        if (pri>50 && pri<128) {
  463. X                            SnapRsrc->Priority = pri;
  464. X                        }
  465. X                    } else {
  466. X                        usage = 1;
  467. X                    }
  468. X                    break;
  469. X                }
  470. X                case 't': textqual: {
  471. X                    if (ARGVAL()) {
  472. X                        SnapRsrc->textqual = hextoint(*argv);
  473. X                    } else {
  474. X                        usage = 1;
  475. X                    }
  476. X                    break;
  477. X                }
  478. X                case 'g': gfxqual: {
  479. X                    if (ARGVAL()) {
  480. X                        SnapRsrc->gfxqual = hextoint(*argv);
  481. X                    } else {
  482. X                        usage = 1;
  483. X                    }
  484. X                    break;
  485. X                }
  486. X                case 'i': insertkey: {
  487. X                    if (ARGVAL()) {
  488. X                        SnapRsrc->insertkey = hextoint(*argv);
  489. X                    } else {
  490. X                        usage = 1;
  491. X                    }
  492. X                    break;
  493. X                }
  494. X                case 'w': cwkey: {
  495. X                    if (ARGVAL()) {
  496. X                        SnapRsrc->cwkey = hextoint(*argv);
  497. X                    } else {
  498. X                        usage = 1;
  499. X                    }
  500. X                    break;
  501. X                }
  502. X                case 'c': chardelay: {
  503. X                    if (ARGVAL()) {
  504. X                        SnapRsrc->chardelay = dectoint(*argv) * 1000;
  505. X                    } else {
  506. X                        usage = 1;
  507. X                    }
  508. X                    break;
  509. X                }
  510. X                case 'l': linedelay: {
  511. X                    if (ARGVAL()) {
  512. X                        SnapRsrc->linedelay = dectoint(*argv) * 1000;
  513. X                    } else {
  514. X                        usage = 1;
  515. X                    }
  516. X                    break;
  517. X                }
  518. X                case 'a': crawlptrn: {
  519. X                    if (ARGVAL()) {
  520. X                        SnapRsrc->CrawlPtrn = hextoint(*argv);
  521. X                    } else {
  522. X                        usage = 1;
  523. X                    }
  524. X                    break;
  525. X                }
  526. X                case 'X': noxerox: {
  527. X                    SnapRsrc->flags &= ~XEROX;
  528. X                    break;
  529. X                }
  530. X                case 'x': xerox: {
  531. X                    SnapRsrc->flags |= XEROX;
  532. X                    break;
  533. X                }
  534. X                case 'E': noearlypatch: {
  535. X                    SnapRsrc->flags &= ~EARLYPATCH;
  536. X                    break;
  537. X                }
  538. X                case 'e': earlypatch: {
  539. X                    SnapRsrc->flags |= EARLYPATCH;
  540. X                    break;
  541. X                }
  542. X                case 'R': fakeunderscore: {
  543. X                    SnapRsrc->flags &= ~TRUEUNDERSCORE;
  544. X                    break;
  545. X                }
  546. X                case 'r': realunderscore: {
  547. X                    SnapRsrc->flags |= TRUEUNDERSCORE;
  548. X                    break;
  549. X                }
  550. X                case 'J': nojoinlong: {
  551. X                    SnapRsrc->flags &= ~JOINLONG;
  552. X                    break;
  553. X                }
  554. X                case 'j': joinlong: {
  555. X                    SnapRsrc->flags |= JOINLONG;
  556. X                    break;
  557. X                }
  558. X                case 'A': append:
  559. X                case 'P': prepend: {
  560. X                    char *dest = (**argv == 'A' ?
  561. X                      &SnapRsrc->Append[0] : &SnapRsrc->Prepend[0]);
  562. X                    if (*++(*argv) || (--argc && ++argv)) { /* "" is ok */
  563. X                        char *src = *argv;
  564. X                        WORD i = 16;
  565. X                        while (*src && i--) {
  566. X                            *dest++ = *src++;
  567. X                        }
  568. X                        *dest = '\0';
  569. X                    } else {
  570. X                        usage = 1;
  571. X                    }
  572. X                    break;
  573. X                }
  574. X                case 'u': startunit: {
  575. X                    if (ARGVAL()) {
  576. X                        switch(dectoint(*argv)) {
  577. X                            case 1: {
  578. X                                SnapRsrc->StartUnit = UNIT_CHAR;
  579. X                                break;
  580. X                            }
  581. X                            case 0:
  582. X                            default: {
  583. X                                SnapRsrc->StartUnit = UNIT_FRAME;
  584. X                                break;
  585. X                            }
  586. X                        }
  587. X                    } else {
  588. X                        usage = 1;
  589. X                    }
  590. X                    break;
  591. X                }
  592. X                case 'b': planemask: {
  593. X                    if (ARGVAL()) {
  594. X                        SnapRsrc->FrameMask = hextoint(*argv);
  595. X                    } else {
  596. X                        usage = 1;
  597. X                    }
  598. X                    break;
  599. X                }
  600. X                case 'o': gadoffset: {
  601. X                    if (ARGVAL()) {
  602. X                        SnapRsrc->GadOffset = dectoint(*argv);
  603. X                    } else {
  604. X                        usage = 1;
  605. X                    }
  606. X                    break;
  607. X                }
  608. X                case 'C': cachesize: {
  609. X                    if (ARGVAL()) {
  610. X                        SnapRsrc->CacheSize = dectoint(*argv);
  611. X                    } else {
  612. X                        usage = 1;
  613. X                    }
  614. X                    break;
  615. X                }
  616. X                case 'B': badchar: {
  617. X                    if (ARGVAL()) {
  618. X                        SnapRsrc->BadChar = dectoint(*argv);
  619. X                    } else {
  620. X                        usage = 1;
  621. X                    }
  622. X                    break;
  623. X                }
  624. X                case 'Q': quit: {
  625. X                    Signal(SnapRsrc->Task, SIGBREAKF_CTRL_C);
  626. X                    exit(0);
  627. X                }
  628. X                case '?': {
  629. X                    usage = 1;
  630. X                    break;
  631. X                }
  632. X                default: {
  633. X                    printf("Bad option: -%c.\n", **argv);
  634. X                    usage = 1;
  635. X                    break;
  636. X                }
  637. X            }
  638. X        } else {
  639. X            (VOID)strupr(*argv);
  640. X            if (!strcmp(*argv, "PRIORITY")) {
  641. X                (*argv)[1] = '\0';                  /* Fake no argument */
  642. X                goto priority;                      /* Terrible, ain't it? */
  643. X            } else if (!strcmp(*argv, "TEXTQUAL")) {
  644. X                (*argv)[1] = '\0';
  645. X                goto textqual;
  646. X            } else if (!strcmp(*argv, "GFXQUAL")) {
  647. X                (*argv)[1] = '\0';
  648. X                goto gfxqual;
  649. X            } else if (!strcmp(*argv, "INSERTKEY")) {
  650. X                (*argv)[1] = '\0';
  651. X                goto insertkey;
  652. X            } else if (!strcmp(*argv, "CWKEY")) {
  653. X                (*argv)[1] = '\0';
  654. X                goto cwkey;
  655. X            } else if (!strcmp(*argv, "PREPEND")) {
  656. X                (*argv)[1] = '\0';
  657. X                goto prepend;
  658. X            } else if (!strcmp(*argv, "APPEND")) {
  659. X                (*argv)[1] = '\0';
  660. X                goto append;
  661. X            } else if (!strcmp(*argv, "CHARDELAY")) {
  662. X                (*argv)[1] = '\0';
  663. X                goto chardelay;
  664. X            } else if (!strcmp(*argv, "LINEDELAY")) {
  665. X                (*argv)[1] = '\0';
  666. X                goto linedelay;
  667. X            } else if (!strcmp(*argv, "CRAWLPTRN")) {
  668. X                (*argv)[1] = '\0';
  669. X                goto crawlptrn;
  670. X            } else if (!strcmp(*argv, "XEROX")) {
  671. X                goto xerox;
  672. X            } else if (!strcmp(*argv, "NOXEROX")) {
  673. X                goto noxerox;
  674. X            } else if (!strcmp(*argv, "EARLYPATCH")) {
  675. X                goto earlypatch;
  676. X            } else if (!strcmp(*argv, "NOEARLYPATCH")) {
  677. X                goto noearlypatch;
  678. X            } else if (!strcmp(*argv, "TRUEUNDERSCORE")) {
  679. X                goto realunderscore;
  680. X            } else if (!strcmp(*argv, "FAKEUNDERSCORE")) {
  681. X                goto fakeunderscore;
  682. X            } else if (!strcmp(*argv, "JOINLONG")) {
  683. X                goto joinlong;
  684. X            } else if (!strcmp(*argv, "NOJOINLONG")) {
  685. X                goto nojoinlong;
  686. X            } else if (!strcmp(*argv, "STARTUNIT")) {
  687. X                (*argv)[1] = '\0';
  688. X                goto startunit;
  689. X            } else if (!strcmp(*argv, "PLANEMASK")) {
  690. X                (*argv)[1] = '\0';
  691. X                goto planemask;
  692. X            } else if (!strcmp(*argv, "GADOFFSET")) {
  693. X                (*argv)[1] = '\0';
  694. X                goto gadoffset;
  695. X            } else if (!strcmp(*argv, "CACHESIZE")) {
  696. X                (*argv)[1] = '\0';
  697. X                goto cachesize;
  698. X            } else if (!strcmp(*argv, "BADCHAR")) {
  699. X                (*argv)[1] = '\0';
  700. X                goto badchar;
  701. X            } else if (!strcmp(*argv, "QUIT")) {
  702. X                goto quit;
  703. X            } else if (strcmp(*argv, "?")) {
  704. X                printf("Bad switch/keyword: %s.\n", *argv);
  705. X            }
  706. X            usage = 1;
  707. X        }
  708. X    }
  709. X
  710. X    if (usage) {
  711. X        puts("Usage:");
  712. X        puts(" snap -pNN -tXX -gXX -iXX -wXX -Pstr -Astr -cNN -lNN -aXXXX");
  713. X        puts("   -x -X -e -E -r -R -j -J -uN -bXX -oNN -CNN -BNN -Q");
  714. X        puts(" or");
  715. X        puts(" snap PRIORITY/k TEXTQUAL/k GFXQUAL/k INSERTKEY/k CWKEY/k");
  716. X        puts("   PREPEND/k APPEND/k CHARDELAY/k LINEDELAY/k CRAWLPTRN/k");
  717. X        puts("   XEROX/s NOXEROX/s EARLYPATCH/s NOEARLYPATCH/s STARTUNIT/k");
  718. X        puts("   TRUEUNDERSCORE/s FAKEUNDERSCORE/s JOINLONG/s NOJOINLONG/s");
  719. X        puts("   PLANEMASK/k GADOFFSET/k CACHESIZE/k BADCHAR/s QUIT/s");
  720. X    }
  721. X
  722. X      /* Tell him there are new settings available */
  723. X    Signal(SnapRsrc->Task, SIGBREAKF_CTRL_F);
  724. X}
  725. END_OF_FILE
  726. if test 12211 -ne `wc -c <'source/settings.c'`; then
  727.     echo shar: \"'source/settings.c'\" unpacked with wrong size!
  728. fi
  729. # end of 'source/settings.c'
  730. fi
  731. if test -f 'source/windows.c' -a "${1}" != "-c" ; then 
  732.   echo shar: Will not clobber existing file \"'source/windows.c'\"
  733. else
  734. echo shar: Extracting \"'source/windows.c'\" \(10836 characters\)
  735. sed "s/^X//" >'source/windows.c' <<'END_OF_FILE'
  736. X/* Auto: make
  737. X*/
  738. X
  739. XIMPORT struct ArpBase *ArpBase;
  740. X
  741. Xstruct Window *ControlWindow = NULL;
  742. XIMPORT struct MsgPort *Sharedport;
  743. XIMPORT WORD Sharedrefs;
  744. X
  745. XIMPORT LONG TitleBarHeight;
  746. XIMPORT LONG ContentsFontHeight;
  747. XIMPORT struct RastPort MyRP;
  748. X
  749. X#define IDCMPFLAGS (MOUSEMOVE|NEWSIZE|CLOSEWINDOW|GADGETUP|ACTIVEWINDOW|INACTIVEWINDOW|MOUSEBUTTONS)
  750. X
  751. XUBYTE *WindowTitle = (UBYTE *)"Snap (c) 1989 Mikael Karlsson";
  752. X
  753. Xstruct Image DiskImage = {
  754. X    0, -1,
  755. X    16, 8, 1,
  756. X    NULL,
  757. X    0x01, 0x00,
  758. X    NULL
  759. X};
  760. X
  761. Xstruct Gadget DiskGad = {
  762. X    NULL,
  763. X    0, 1,
  764. X    16, 8,
  765. X    GADGIMAGE|GADGHCOMP|GRELRIGHT,
  766. X    RELVERIFY,
  767. X    BOOLGADGET,
  768. X    (APTR)&DiskImage,
  769. X    NULL,
  770. X    NULL,
  771. X    0L,
  772. X    NULL,
  773. X    DISKGAD,
  774. X    NULL,
  775. X};
  776. X
  777. Xstruct Gadget VProp = {
  778. X    NULL,
  779. X    -15, 10,
  780. X    16, -10,
  781. X    GADGHCOMP|GRELRIGHT|GRELHEIGHT,
  782. X    GADGIMMEDIATE|FOLLOWMOUSE|RELVERIFY,
  783. X    PROPGADGET,
  784. X    NULL,
  785. X    NULL,
  786. X    NULL,
  787. X    0L,
  788. X    NULL,
  789. X    VPROP,
  790. X    NULL
  791. X};
  792. X
  793. Xstruct Gadget HProp = {
  794. X    NULL,
  795. X    1, -8,
  796. X    -15, 9,
  797. X    GADGHCOMP|GRELBOTTOM|GRELWIDTH,
  798. X    GADGIMMEDIATE|FOLLOWMOUSE|RELVERIFY,
  799. X    PROPGADGET,
  800. X    NULL,
  801. X    NULL,
  802. X    NULL,
  803. X    0L,
  804. X    NULL,
  805. X    HPROP,
  806. X    NULL
  807. X};
  808. X
  809. Xstruct PropInfo VInfo = {
  810. X    AUTOKNOB|FREEVERT,
  811. X    0, 0,
  812. X    MAXBODY, MAXBODY,
  813. X    0, 0, 0, 0, 0, 0
  814. X};
  815. X
  816. Xstruct PropInfo HInfo = {
  817. X    AUTOKNOB|FREEHORIZ,
  818. X    0, 0,
  819. X    MAXBODY, MAXBODY,
  820. X    0, 0, 0, 0, 0, 0
  821. X};
  822. X
  823. Xstruct Image VImage = {
  824. X    0, 0, 0, 0, 0, NULL, 0, 0, NULL
  825. X};
  826. Xstruct Image HImage = {
  827. X    0, 0, 0, 0, 0, NULL, 0, 0, NULL
  828. X};
  829. X
  830. X/* Window structure for snapped gfx */
  831. Xstruct NewWindow Nw = {
  832. X    0, 1,             /* LeftEdge, TopEdge  */
  833. X    0, 0,             /* Width, Height */
  834. X    -1, -1,           /* DetailPen, BlockPen */
  835. X    NULL,             /* IDCMPFlags */
  836. X    WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|WINDOWSIZING|SMART_REFRESH|NOCAREREFRESH|RMBTRAP,
  837. X    NULL, NULL,       /* FirstGadget, CheckMark */
  838. X    NULL,
  839. X    NULL, NULL,       /* Screen, BitMap */
  840. X    32, 32,           /* MinWidth, MinHeight */
  841. X    0, 0,           /* MaxWidth, MaxHeight */
  842. X    WBENCHSCREEN      /* Type */
  843. X};
  844. X
  845. XSHORT Coords3[5][2] = {
  846. X    {  0,  0},
  847. X    { 74,  0},
  848. X    { 74, 10},
  849. X    {  0, 10},
  850. X    {  0,  0}
  851. X};
  852. X
  853. XSHORT Coords2[5][2] = {
  854. X    {  0,  0},
  855. X    { 74,  0},
  856. X    { 74, 10},
  857. X    {  0, 10},
  858. X    {  0,  0}
  859. X};
  860. X
  861. XSHORT Coords1[5][2] = {
  862. X    {  0,  0},
  863. X    { 34,  0},
  864. X    { 34, 10},
  865. X    {  0, 10},
  866. X    {  0,  0}
  867. X};
  868. X
  869. Xstruct Border Border3 = {
  870. X    42, 0,
  871. X    1, 0,
  872. X    JAM1,
  873. X    5,
  874. X    (SHORT *)&Coords3,
  875. X    NULL
  876. X};
  877. X
  878. Xstruct Border Border2 = {
  879. X    42, 0,
  880. X    1, 0,
  881. X    JAM1,
  882. X    5,
  883. X    (SHORT *)&Coords2,
  884. X    &Border3
  885. X};
  886. X
  887. Xstruct Border Border1 = {
  888. X    4, 0,
  889. X    1, 0,
  890. X    JAM1,
  891. X    5,
  892. X    (SHORT *)&Coords1,
  893. X    &Border2
  894. X};
  895. X
  896. XUBYTE TranspBuf[5];
  897. X
  898. Xstruct StringInfo TranspSI = {
  899. X    TranspBuf,  /* Buf */
  900. X    NULL,       /* UndoBuf */
  901. X    0,          /* BufferPos */
  902. X    4,          /* MaxChars */
  903. X    0,          /* DispPos */
  904. X    0,          /* UndoPos */
  905. X    0,          /* NumChars */
  906. X    0,          /* DispCount */
  907. X    0, 0,       /* CLeft, CTop */
  908. X    NULL,       /* Layer */
  909. X    0L,         /* LongInt */
  910. X    NULL        /* AltKeyMap */
  911. X};
  912. X
  913. Xstruct Gadget TranspGad = {
  914. X    NULL,
  915. X    5, 16,
  916. X    32, 8,
  917. X    LONGINT,
  918. X    RELVERIFY,
  919. X    STRGADGET,
  920. X    NULL,
  921. X    NULL,
  922. X    NULL,
  923. X    0L,
  924. X    (APTR)&TranspSI,
  925. X    0,
  926. X    NULL,
  927. X};
  928. X
  929. XUBYTE SaveName[256] = "";
  930. XUBYTE SaveDirName[256] = "";
  931. X
  932. Xstruct StringInfo NameSI = {
  933. X    SaveName,   /* Buf */
  934. X    NULL,       /* UndoBuf */
  935. X    0,          /* BufferPos */
  936. X    255,        /* MaxChars */
  937. X    0,          /* DispPos */
  938. X    0,          /* UndoPos */
  939. X    0,          /* NumChars */
  940. X    0,          /* DispCount */
  941. X    0, 0,       /* CLeft, CTop */
  942. X    NULL,       /* Layer */
  943. X    0L,         /* LongInt */
  944. X    NULL        /* AltKeyMap */
  945. X};
  946. X
  947. Xstruct Gadget NameGad = {
  948. X    &TranspGad,
  949. X    5, 16,
  950. X    32, 8,
  951. X    NULL,
  952. X    NULL,
  953. X    NULL,
  954. X    NULL,
  955. X    NULL,
  956. X    NULL,
  957. X    0L,
  958. X    NULL,
  959. X    NAMEGAD,
  960. X    NULL,
  961. X};
  962. X
  963. Xstruct Gadget SaveGad = {
  964. X    &NameGad,
  965. X    5, 16,
  966. X    32, 8,
  967. X    GADGHCOMP,
  968. X    RELVERIFY,
  969. X    BOOLGADGET,
  970. X    NULL,
  971. X    NULL,
  972. X    NULL,
  973. X    0L,
  974. X    NULL,
  975. X    SAVEGAD,
  976. X    NULL,
  977. X};
  978. X
  979. X/* Window structure for control window */
  980. Xstruct NewWindow NewCW = {
  981. X  10, 10,           /* LeftEdge, TopEdge  */
  982. X  320, 40,          /* Width, Height */
  983. X  -1, -1,           /* DetailPen, BlockPen */
  984. X  NULL,             /* IDCMPFlags */
  985. X  WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|SMART_REFRESH|ACTIVATE|NOCAREREFRESH,
  986. X  NULL, NULL,       /* FirstGadget, CheckMark */
  987. X  (UBYTE *)"Snap Control Window",
  988. X  NULL, NULL,       /* Screen, BitMap */
  989. X  32, 32,           /* MinWidth, MinHeight */
  990. X  -1, -1,           /* MaxWidth, MaxHeight */
  991. X  WBENCHSCREEN      /* Type */
  992. X};
  993. X
  994. Xstruct FileRequester NameFR = {
  995. X    "Save picture as...",
  996. X    (BYTE *)SaveName,
  997. X    (BYTE *)SaveDirName,
  998. X    NULL,
  999. X    NULL,
  1000. X    NULL,
  1001. X    NULL,
  1002. X    NULL
  1003. X};
  1004. X
  1005. Xstruct Window *opensharedwindow(nw)
  1006. Xstruct NewWindow *nw;
  1007. X{
  1008. X    struct Window *win;
  1009. X    struct Screen scr;
  1010. X
  1011. X    if (Sharedport) {
  1012. X        nw->IDCMPFlags = NULL;
  1013. X    } else {
  1014. X        nw->IDCMPFlags = IDCMPFLAGS;
  1015. X    }
  1016. X    if (!GetScreenData((char *)&scr, (LONG)sizeof(struct Screen),
  1017. X      WBENCHSCREEN, NULL)) {
  1018. X        return NULL;     /* No WB */
  1019. X    }
  1020. X    if (nw->TopEdge+nw->Height > scr.Height) {
  1021. X        nw->TopEdge = scr.Height-nw->Height;
  1022. X    }
  1023. X    if (nw->LeftEdge+nw->Width > scr.Width) {
  1024. X        nw->LeftEdge = scr.Width-nw->Width;
  1025. X    }
  1026. X    if (nw->TopEdge < 0) {
  1027. X        nw->TopEdge = 0;
  1028. X    }
  1029. X    if (nw->LeftEdge < 0) {
  1030. X        nw->LeftEdge = 0;
  1031. X    }
  1032. X    if (nw->TopEdge+nw->Height > scr.Height) {
  1033. X        nw->Height = scr.Height-nw->TopEdge;
  1034. X    }
  1035. X    if (nw->LeftEdge+nw->Width > scr.Width) {
  1036. X        nw->Width = scr.Width-nw->LeftEdge;
  1037. X    }
  1038. X
  1039. X    if (win = OpenWindow(nw)) {
  1040. X        if (Sharedport) {
  1041. X            win->UserPort = Sharedport;
  1042. X            ModifyIDCMP(win, IDCMPFLAGS);
  1043. X        } else {
  1044. X            Sharedport = win->UserPort;
  1045. X        }
  1046. X        ++Sharedrefs;
  1047. X    }
  1048. X    return(win);
  1049. X}
  1050. X
  1051. X
  1052. XVOID closesharedwindow(win)
  1053. Xstruct Window *win;
  1054. X{
  1055. X    Forbid();
  1056. X    Sharedrefs--;
  1057. X    if (Sharedrefs > 0) {
  1058. X        REGISTER struct IntuiMessage *im, *succ;
  1059. X        im = (struct IntuiMessage *)win->UserPort->mp_MsgList.lh_Head;
  1060. X        while (succ = (struct IntuiMessage *)im->ExecMessage.mn_Node.ln_Succ) {
  1061. X            if (im->IDCMPWindow == win) {
  1062. X                Remove(im);
  1063. X                ReplyMsg(im);
  1064. X            }
  1065. X            im = succ;
  1066. X        }
  1067. X        win->UserPort = NULL;
  1068. X        ModifyIDCMP(win, MENUVERIFY);     /* NEVER occurs */
  1069. X    } else
  1070. X        Sharedport = NULL;
  1071. X    Permit();
  1072. X    CloseWindow(win);
  1073. X}
  1074. X
  1075. XVOID SetUpBorder(Border, Gad)
  1076. Xstruct Border *Border;
  1077. Xstruct Gadget *Gad;
  1078. X{
  1079. X    Border->LeftEdge = Gad->LeftEdge-1;
  1080. X    Border->TopEdge = Gad->TopEdge-1;
  1081. X    Border->XY[2] = Border->XY[4] = Gad->Width+1;
  1082. X    Border->XY[5] = Border->XY[7] = Gad->Height+1;
  1083. X}
  1084. X
  1085. XVOID AdjustSize(GS)
  1086. Xstruct GfxSnap *GS;
  1087. X{
  1088. X    ULONG w = GS->window->Width - 18;
  1089. X    ULONG h = GS->window->Height - GS->VProp.TopEdge - 9;
  1090. X    ULONG vb, hb;
  1091. X
  1092. X    vb = hb = MAXBODY;
  1093. X
  1094. X    if (w < GS->width) {
  1095. X        hb = w * (ULONG)MAXBODY / GS->width;
  1096. X    }
  1097. X    if (h < GS->height) {
  1098. X        vb = h * (ULONG)MAXBODY / GS->height;
  1099. X    }
  1100. X    NewModifyProp(&GS->VProp, GS->window, NULL, (ULONG)AUTOKNOB|FREEVERT,
  1101. X      0L, 0L, (ULONG)MAXBODY, vb, 1L);
  1102. X    NewModifyProp(&GS->HProp, GS->window, NULL, (ULONG)AUTOKNOB|FREEHORIZ,
  1103. X      0L, 0L, hb, (ULONG)MAXBODY, 1L);
  1104. X    InitRastPort(&MyRP);
  1105. X    MyRP.BitMap = &GS->BM;
  1106. X    ClipBlit(&MyRP, 0L, 0L, GS->window->RPort,
  1107. X      2L, (LONG)GS->VProp.TopEdge, w, h, 0xC0L);
  1108. X}
  1109. X
  1110. XVOID SyncGS(GS)
  1111. Xstruct GfxSnap *GS;
  1112. X{
  1113. X    ULONG w = GS->window->Width - 18;
  1114. X    ULONG h = GS->window->Height - GS->VProp.TopEdge - 9;
  1115. X    ULONG vpos, hpos;
  1116. X    LONG temp;
  1117. X
  1118. X    temp = GS->width - w;
  1119. X    if (temp <= 0) {
  1120. X        hpos = 0;
  1121. X    } else {
  1122. X        hpos = temp * (LONG)GS->HInfo.HorizPot / MAXBODY;
  1123. X        if (hpos > temp) {
  1124. X            hpos = temp;
  1125. X        }
  1126. X    }
  1127. X    temp = GS->height - h;
  1128. X    if (temp <= 0) {
  1129. X        vpos = 0;
  1130. X    } else {
  1131. X        vpos = temp * (LONG)GS->VInfo.VertPot / MAXBODY;
  1132. X        if (vpos > temp) {
  1133. X            vpos = temp;
  1134. X        }
  1135. X    }
  1136. X    InitRastPort(&MyRP);
  1137. X    MyRP.BitMap = &GS->BM;
  1138. X    ClipBlit(&MyRP, hpos, vpos, GS->window->RPort,
  1139. X      2L, (LONG)GS->VProp.TopEdge, w, h, 0xC0L);
  1140. X}
  1141. X
  1142. XSHORT OpenCW()
  1143. X{
  1144. X    WORD temp;
  1145. X
  1146. X    FixHeights();
  1147. X
  1148. X    NewCW.Height = TitleBarHeight + ContentsFontHeight * 2 + 12;
  1149. X    ControlWindow = opensharedwindow(&NewCW);
  1150. X    if (!ControlWindow) {
  1151. X        return 0;
  1152. X    }
  1153. X    SaveGad.TopEdge = NameGad.TopEdge = TitleBarHeight + 2;
  1154. X    SaveGad.Height = NameGad.Height = TranspGad.Height = ContentsFontHeight+2;
  1155. X    TranspGad.TopEdge = SaveGad.TopEdge + SaveGad.Height + 3;
  1156. X
  1157. X    SaveGad.LeftEdge = 4L;
  1158. X    SaveGad.Width = TextLength(ControlWindow->RPort, "Save", 4L) + 1;
  1159. X    if (Sharedrefs == 1) {       /* No snap window, just control window? */
  1160. X        SaveGad.Flags |= GADGDISABLED;
  1161. X    } else {
  1162. X        SaveGad.Flags &= ~GADGDISABLED;
  1163. X    }
  1164. X
  1165. X    NameGad.LeftEdge = SaveGad.LeftEdge +
  1166. X      TextLength(ControlWindow->RPort, "Save as ", 8L);
  1167. X    temp = ControlWindow->Width - 4 - NameGad.LeftEdge;
  1168. X    NameGad.Width =
  1169. X      temp - (temp % TextLength(ControlWindow->RPort, " ", 1L)) + 1;
  1170. X
  1171. X    TranspGad.LeftEdge = SaveGad.LeftEdge +
  1172. X      TextLength(ControlWindow->RPort, "Transparent color ", 18L);
  1173. X    TranspGad.Width = TextLength(ControlWindow->RPort, "0000", 4L);
  1174. X
  1175. X    SetUpBorder(&Border1, &SaveGad);
  1176. X    SetUpBorder(&Border2, &NameGad);
  1177. X    SetUpBorder(&Border3, &TranspGad);
  1178. X
  1179. X    ++TranspGad.LeftEdge;
  1180. X    ++TranspGad.TopEdge;
  1181. X
  1182. X    if (ArpBase) {
  1183. X        NameGad.Flags = GADGHCOMP;
  1184. X        NameGad.Activation = RELVERIFY;
  1185. X        NameGad.GadgetType = BOOLGADGET;
  1186. X        NameGad.SpecialInfo = NULL;
  1187. X    } else {
  1188. X        NameGad.Flags = SELECTED;
  1189. X        NameGad.Activation = NULL;
  1190. X        NameGad.GadgetType = STRGADGET;
  1191. X        NameGad.SpecialInfo = (APTR)&NameSI;
  1192. X        ++NameGad.LeftEdge;         /* Adjust string gadget position */
  1193. X        ++NameGad.TopEdge;          /* Adjust string gadget position */
  1194. X    }
  1195. X
  1196. X    strcpy(SaveName, "Snap.pic");
  1197. X    strcpy(TranspBuf, "0");
  1198. X    TranspSI.LongInt = 0L;
  1199. X
  1200. X    SetAPen(ControlWindow->RPort, 1L);
  1201. X    SetBPen(ControlWindow->RPort, 0L);
  1202. X    SetDrMd(ControlWindow->RPort, JAM2);
  1203. X    Move(ControlWindow->RPort,
  1204. X      5L, (LONG)SaveGad.TopEdge + 1 + ControlWindow->RPort->Font->tf_Baseline);
  1205. X    Text(ControlWindow->RPort, "Save as", 7L);
  1206. X    Move(ControlWindow->RPort,
  1207. X      5L, (LONG)TranspGad.TopEdge + ControlWindow->RPort->Font->tf_Baseline);
  1208. X    Text(ControlWindow->RPort, "Transparent color", 17L);
  1209. X    DrawBorder(ControlWindow->RPort, &Border1, 0L, 0L);
  1210. X    AddGList(ControlWindow, &SaveGad, -1L, 3L, NULL);
  1211. X    RefreshGList(&SaveGad, ControlWindow, NULL, 3L);
  1212. X    if (ArpBase) {
  1213. X        GadText(&NameGad, SaveName, 8L);
  1214. X    } else {
  1215. X        ActivateGadget(&NameGad, ControlWindow, NULL);
  1216. X    }
  1217. X    return 1;
  1218. X}
  1219. END_OF_FILE
  1220. if test 10836 -ne `wc -c <'source/windows.c'`; then
  1221.     echo shar: \"'source/windows.c'\" unpacked with wrong size!
  1222. fi
  1223. # end of 'source/windows.c'
  1224. fi
  1225. if test -f 'startsnap.rexx' -a "${1}" != "-c" ; then 
  1226.   echo shar: Will not clobber existing file \"'startsnap.rexx'\"
  1227. else
  1228. echo shar: Extracting \"'startsnap.rexx'\" \(13368 characters\)
  1229. sed "s/^X//" >'startsnap.rexx' <<'END_OF_FILE'
  1230. X/* Arexx script to help people with Snap arguments */
  1231. X
  1232. Xsignal on error
  1233. X
  1234. Xif ~show('l', "rexxarplib.library") then do
  1235. X    check = addlib('rexxsupport.library',0,-30,0)
  1236. X    check = addlib('rexxmathlib.library',0,-30,0)
  1237. X    check = addlib('rexxarplib.library',0,-30,0)
  1238. Xend
  1239. X
  1240. Xif ~exists("fonts:helvetica/15") then do
  1241. X    say "Actually I need font 'Helvetica 15', but I'll try anyway."
  1242. Xend
  1243. X
  1244. Xbool.0 = 'OFF'; bool.1 = 'ON'
  1245. X
  1246. X/* Fix window dimensions */
  1247. X
  1248. Xscreen.width = ScreenCols()
  1249. Xscreen.height = ScreenRows()
  1250. X
  1251. Xwindow.width = 530
  1252. Xwindow.height = 200
  1253. Xwindow.leftedge = (screen.width-window.width)/2
  1254. Xwindow.topedge = (screen.height-window.height)/2
  1255. X
  1256. X/* Set up a host */
  1257. Xparse version 'V' vers .
  1258. Xsignal on syntax
  1259. Xcall stop(SNAPHOST)
  1260. Xsyntax:
  1261. Xif vers > 1.06 then
  1262. X    address AREXX  "'call CreateHost(SNAPHOST, SNAPPORT)'"
  1263. Xelse
  1264. X    "runwsh >nil:" "'call CreateHost(SNAPHOST, SNAPPORT)'"
  1265. X
  1266. X/*
  1267. X*   Wait for a while until host is ready.
  1268. X*/
  1269. Xdo for 50 while ~show('Ports','SNAPHOST')
  1270. X   call delay 10  /* 200 ms */
  1271. Xend
  1272. X
  1273. Xcall SetReqColor(SNAPHOST, BLOCKPEN, 1)
  1274. Xcall SetReqColor(SNAPHOST, DETAILPEN, 0)
  1275. X
  1276. X/*
  1277. X*   Open the window
  1278. X*/
  1279. Xwindow.idcmp = 'CLOSEWINDOW+GADGETUP+RAWKEY'
  1280. Xwindow.flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+ACTIVATE'
  1281. X
  1282. Xtitle = "Setup tool for Snap"
  1283. X
  1284. Xcall OpenWindow(SNAPHOST, window.leftedge, window.topedge, window.width, ,
  1285. X                window.height, window.idcmp, window.flags, title)
  1286. X
  1287. Xcall ModifyHost(SNAPHOST, RAWKEY, "RAWKEY %c")
  1288. X
  1289. Xif exists("fonts:Helvetica/15") then do
  1290. X    call SetFont(SNAPHOST, "Helvetica.font", 15)
  1291. Xend
  1292. X
  1293. Xsignal dotext
  1294. X/* --- Start of texts ---
  1295. X"      Please hold on..."    5  20 60 ""
  1296. X"Priority:"                  5  40  6 "Input handler priority."
  1297. X"Insert key:"              215  60  9 "Key used with Left Amiga to insert."
  1298. X"Window key:"              215  80  9 "Key used with Left Amiga to open control window."
  1299. X"Char delay:"              215 100  9 "Delay after each inserted character"
  1300. X"Line delay:"              215 120  9 "Delay after each inserted newline."
  1301. X"Bit mask:"                215 140  9 "Bit planes to draw selection frame into."
  1302. X"Starting unit:"           215 160  9 "Unit in which to start snapping."
  1303. X"Prepend:"                   5 180  6 "Characters added in front of each line in modified inserts."
  1304. X"Append:"                  215 180  6 "Characters added at the end of each line in modified inserts."
  1305. X"Selection frame pattern:" 345  40 19 "Pattern used for crawling dots in selection frame."
  1306. X"Text qualifier:"            5  60 11 "Qualifier used when snapping characters."
  1307. X"Gfx qualifier:"           110  60 11 "Qualifier used when snapping graphics."
  1308. XEOT
  1309. X--- End of texts --- */
  1310. X
  1311. Xdotext:
  1312. Xtextlines = sigl+1
  1313. X
  1314. Xcall SetReqColor(SNAPHOST, 'BOXPEN', 0)
  1315. Xcall SetReqColor(SNAPHOST, 'SHADOWPEN', 0)
  1316. Xcall SetAPen(SNAPHOST, 1)
  1317. Xdo i=1 while sourceline(textlines+i) ~= "EOT"
  1318. X    parse value sourceline(textlines+i) with '"'text'"' x y w . '"'help'"'
  1319. X    call AddGadget(SNAPHOST, x, y, 'HLP'i, copies(' ',w), "HELP "help)
  1320. Xend
  1321. X
  1322. Xcall SetReqColor(SNAPHOST, 'BOXPEN', 2)
  1323. Xcall SetReqColor(SNAPHOST, 'SHADOWPEN', 3)
  1324. Xdo i=1 while sourceline(textlines+i) ~= "EOT"
  1325. X    parse value sourceline(textlines+i) with '"'text'"' x y w . '"'help'"'
  1326. X    call Move(SNAPHOST, x, y+10); call Text(SNAPHOST, text)
  1327. Xend
  1328. X
  1329. X/* Set up some nice gadgets */
  1330. Xx = 65
  1331. Xdo i=51 for 5
  1332. X    call AddGadget(SNAPHOST,  x, 40, 'PR'i, ''i'', 'PRIORITY 'i); x = x+27
  1333. Xend
  1334. X
  1335. Xinscode.1 = 23;  inscode.2 = 15;  inscode.3 = 34
  1336. Xinskey.1 = 'I';  inskey.2 = 'Y';  inskey.3 = 'V'
  1337. Xx = 300
  1338. Xdo i=1 for 3
  1339. X    call AddGadget(SNAPHOST, x, 60, 'INS'i, inskey.i, 'INSKEY 'i); x = x+20
  1340. Xend
  1341. X
  1342. Xcwcode.1 = 17;  cwcode.2 = 51;  cwcode.3 = 24
  1343. Xcwkey.1 = 'W';  cwkey.2 = 'C';  cwkey.3 = 'O'
  1344. Xx = 300
  1345. Xdo i=1 for 3
  1346. X    call AddGadget(SNAPHOST, x, 80, 'CW'i, cwkey.i, 'CWKEY 'i); x = x+20
  1347. Xend
  1348. X
  1349. Xx = 300
  1350. Xdo i=0 for 3
  1351. X    call AddGadget(SNAPHOST, x, 100, 'CDL'i, i, 'CDELAY 'i); x = x+20
  1352. Xend
  1353. X
  1354. Xx = 300
  1355. Xdo i=0 for 3
  1356. X    call AddGadget(SNAPHOST, x, 120, 'LDL'i, i, 'LDELAY 'i); x = x+20
  1357. Xend
  1358. X
  1359. Xx = 300
  1360. Xdo i=0 for 3
  1361. X    call AddGadget(SNAPHOST, x, 140, 'MSK'i, i, 'MASK 'i); x = x+20
  1362. Xend
  1363. X
  1364. Xcall AddGadget(SNAPHOST, 300, 160, 'UNT'0, "Frame", 'UNIT 0')
  1365. Xcall AddGadget(SNAPHOST, 350, 160, 'UNT'1, "Char ", 'UNIT 1')
  1366. X
  1367. Xcall AddGadget(SNAPHOST, 365,  60, 'XERX', 'Immediate insert', 'XEROX')
  1368. Xcall AddGadget(SNAPHOST, 365,  80, 'JOIN', 'Join long lines ', 'JOIN')
  1369. Xcall AddGadget(SNAPHOST, 365, 100, 'PTCH', 'Early patch     ', 'PATCH')
  1370. Xcall AddGadget(SNAPHOST, 365, 120, 'USCR', 'True underscore ', 'UNDERSCORE')
  1371. X
  1372. Xcall AddGadget(SNAPHOST,  70, 180, 'PREP', "> ", 'PREP %g', 128)
  1373. Xcall AddGadget(SNAPHOST, 280, 180,  'APP',   "",  'APP %g', 128)
  1374. X
  1375. Xcall SetReqColor(SNAPHOST, 'SHADOWPEN', 0L)
  1376. Xy = 18
  1377. Xdo i=0 for 16
  1378. X    call AddGadget(SNAPHOST, 510,  y, 'PAT'i, ' ', 'PATTERN 'i); y = y+11
  1379. Xend
  1380. Xcall SetReqColor(SNAPHOST, 'SHADOWPEN', 3L)
  1381. X
  1382. Xbit.1 = 0; desc.1 = 'Left Shift '
  1383. Xbit.2 = 1; desc.2 = 'Right Shift'
  1384. Xbit.3 = 3; desc.3 = 'Control    '
  1385. Xbit.4 = 4; desc.4 = 'Left Alt   '
  1386. Xbit.5 = 5; desc.5 = 'Right Alt  '
  1387. Xbit.6 = 6; desc.6 = 'Left Amiga '
  1388. Xbit.7 = 7; desc.7 = 'Right Amiga'
  1389. X
  1390. Xy = 75
  1391. Xdo i=1 for 7
  1392. X    call AddGadget(SNAPHOST,   5, y,  'TQ'i, desc.i, 'TEXTQUAL 'i)
  1393. X    call AddGadget(SNAPHOST, 110, y,  'GQ'i, desc.i, 'GFXQUAL 'i)
  1394. X    y = y+15
  1395. Xend
  1396. X
  1397. Xcall AddGadget(SNAPHOST, 430, 172, 'APPLY', ' Apply\settings', 'APPLY')
  1398. X
  1399. X/* Open our host port */
  1400. Xcall openport(SNAPPORT)
  1401. X
  1402. Xstart:
  1403. X
  1404. Xcall ShowText("     Setting defaults...")
  1405. Xpri = 51;           call SetGadget(SNAPHOST, 'PR51', 'ON')
  1406. Xtextqual = '0040'x; call SetGadget(SNAPHOST,  'TQ6', 'ON')
  1407. Xgfxqual  = '0080'x; call SetGadget(SNAPHOST,  'GQ7', 'ON')
  1408. Xinskey = 1;         call SetGadget(SNAPHOST, 'INS1', 'ON')
  1409. Xcwkey = 1;          call SetGadget(SNAPHOST,  'CW1', 'ON')
  1410. Xcdelay = 0;         call SetGadget(SNAPHOST, 'CDL0', 'ON')
  1411. Xldelay = 0;         call SetGadget(SNAPHOST, 'LDL0', 'ON')
  1412. Xpattern = '7777'x;
  1413. Xdo i=0 for 16
  1414. X    if bittst(pattern,i) then call SetGadget(SNAPHOST, 'PAT'i, 'ON')
  1415. Xend
  1416. Xunit = 0;           call SetGadget(SNAPHOST, 'UNT0', 'ON')
  1417. Xxerox = 0
  1418. Xpatch = 0
  1419. Xjoin = 0
  1420. Xunderscore = 1;     call SetGadget(SNAPHOST, 'USCR', 'ON')
  1421. Xplanes = '00'x
  1422. X
  1423. Xcall ShowText("     Select options. Click here for help.")
  1424. X
  1425. Xhelp.1 = "Click text (eg 'Priority') for help. Click here for more help."
  1426. Xhelp.2 = "Close window for correct command line. Click for more."
  1427. Xhelp.3 = "Click 'Apply settings' to reconfigure Snap."
  1428. Xmaxhelp = 3
  1429. X
  1430. Xkeycmd. = ""
  1431. Xkeycmd.95 = "HELP";    keycmd.25 = "PRIORITY";  keycmd.16 = "CLOSEWINDOW"
  1432. Xkeycmd.23 = "INSKEY";  keycmd.51 = "CDELAY";    keycmd.40 = "LDELAY"
  1433. Xkeycmd.33 = "UNIT";    keycmd.32 = "APPLY"
  1434. X
  1435. Xmain:
  1436. Xquitflag = 0
  1437. Xhelpnum = 1
  1438. X
  1439. Xloop:
  1440. Xif quitflag~=0 then signal done
  1441. X
  1442. Xcall waitpkt(SNAPPORT)
  1443. Xp = getpkt(SNAPPORT)
  1444. Xif p == NULL() then signal loop
  1445. X
  1446. Xcmd = getarg(p)
  1447. Xcall reply(p, 0)
  1448. X
  1449. Xdocmd:
  1450. Xparse var cmd item val .
  1451. Xsignal value item
  1452. X
  1453. Xclosewindow:
  1454. X    quitflag = 1
  1455. X    signal loop
  1456. X
  1457. Xrawkey:
  1458. X    cmd = keycmd.val
  1459. X    if cmd ~= "" then do
  1460. X        signal docmd
  1461. X    end
  1462. X    signal loop
  1463. X
  1464. Xhelp:
  1465. X    parse var cmd item help
  1466. X    if help="" then do
  1467. X        call showtext(help.helpnum)
  1468. X        helpnum = helpnum+1
  1469. X        if helpnum>maxhelp then helpnum = 1
  1470. X    end
  1471. X    else do
  1472. X        call showtext(help)
  1473. X    end
  1474. X    signal loop
  1475. X
  1476. Xpriority:
  1477. X    if val="" then do
  1478. X        val = pri+1
  1479. X        if val>55 then val = 51
  1480. X    end
  1481. X    pri = val
  1482. X    do i=51 for 5
  1483. X        call setgadget(SNAPHOST, 'PR'i, 'OFF')
  1484. X    end
  1485. X    call setgadget(SNAPHOST, 'PR'pri, 'ON')
  1486. X    signal loop
  1487. X
  1488. Xinskey:
  1489. X    if val="" then do
  1490. X        val = inskey+1
  1491. X        if val>3 then val = 1
  1492. X    end
  1493. X    inskey = val
  1494. X    do i=1 for 3
  1495. X        call setgadget(SNAPHOST, 'INS'i, 'OFF')
  1496. X    end
  1497. X    call setgadget(SNAPHOST, 'INS'val, 'ON')
  1498. X    signal loop
  1499. X
  1500. Xcwkey:
  1501. X    if val="" then do
  1502. X        val = cwkey+1
  1503. X        if val>3 then val = 1
  1504. X    end
  1505. X    cwkey = val
  1506. X    do i=1 for 3
  1507. X        call setgadget(SNAPHOST, 'CW'i, 'OFF')
  1508. X    end
  1509. X    call setgadget(SNAPHOST, 'CW'val, 'ON')
  1510. X    signal loop
  1511. X
  1512. Xcdelay:
  1513. X    if val="" then do
  1514. X        val = cdelay+1
  1515. X        if val>2 then val = 0
  1516. X    end
  1517. X    cdelay = val
  1518. X    do i=0 for 3
  1519. X        call setgadget(SNAPHOST, 'CDL'i, 'OFF')
  1520. X    end
  1521. X    call setgadget(SNAPHOST, 'CDL'val, 'ON')
  1522. X    signal loop
  1523. X
  1524. Xldelay:
  1525. X    if val="" then do
  1526. X        val = ldelay+1
  1527. X        if val>2 then val = 0
  1528. X    end
  1529. X    ldelay = val
  1530. X    do i=0 for 3
  1531. X        call setgadget(SNAPHOST, 'LDL'i, 'OFF')
  1532. X    end
  1533. X    call setgadget(SNAPHOST, 'LDL'val, 'ON')
  1534. X    signal loop
  1535. X
  1536. Xunit:
  1537. X    if val="" then do
  1538. X        val = 1-unit
  1539. X    end
  1540. X    unit = val
  1541. X    call setgadget(SNAPHOST, 'UNT0', 'OFF')
  1542. X    call setgadget(SNAPHOST, 'UNT1', 'OFF')
  1543. X    call setgadget(SNAPHOST, 'UNT'unit, 'ON')
  1544. X    signal loop
  1545. X
  1546. Xpattern:
  1547. X    pattern = bitchg(pattern,val)
  1548. X    temp = bittst(pattern,val)
  1549. X    call setgadget(SNAPHOST, 'PAT'val, bool.temp)
  1550. X    signal loop
  1551. X
  1552. Xmask:
  1553. X    planes = bitchg(planes,val)
  1554. X    temp = bittst(planes,val)
  1555. X    call setgadget(SNAPHOST, 'MSK'val, bool.temp)
  1556. X    signal loop
  1557. X
  1558. Xprep:
  1559. X    parse var cmd . ' ' prepend
  1560. X    signal loop
  1561. X
  1562. Xapp:
  1563. X    parse var cmd . ' ' append
  1564. X    signal loop
  1565. X
  1566. Xtextqual:
  1567. X    if bittst(textqual,bit.val) then do
  1568. X        textqual = bitclr(textqual,bit.val)
  1569. X        call setgadget(SNAPHOST, 'TQ'val, 'OFF')
  1570. X    end
  1571. X    else do
  1572. X        call setgadget(SNAPHOST, 'GQ'val, 'OFF')
  1573. X        gfxqual = bitclr(gfxqual,bit.val)
  1574. X        textqual = bitset(textqual,bit.val)
  1575. X        call setgadget(SNAPHOST, 'TQ'val, 'ON')
  1576. X    end
  1577. X    signal loop
  1578. X
  1579. Xgfxqual:
  1580. X    if bittst(gfxqual,bit.val) then do
  1581. X        gfxqual = bitclr(gfxqual,bit.val)
  1582. X        call setgadget(SNAPHOST, 'GQ'val, 'OFF')
  1583. X    end
  1584. X    else do
  1585. X        call setgadget(SNAPHOST, 'TQ'val, 'OFF')
  1586. X        textqual = bitclr(textqual,bit.val)
  1587. X        gfxqual = bitset(gfxqual,bit.val)
  1588. X        call setgadget(SNAPHOST, 'GQ'val, 'ON')
  1589. X    end
  1590. X    signal loop
  1591. X
  1592. Xxerox:
  1593. X    xerox = 1-xerox
  1594. X    call setgadget(SNAPHOST, 'XERX', bool.xerox)
  1595. X    signal loop
  1596. X
  1597. Xjoin:
  1598. X    join = 1-join
  1599. X    call setgadget(SNAPHOST, 'JOIN', bool.join)
  1600. X    signal loop
  1601. X
  1602. Xpatch:
  1603. X    patch = 1-patch
  1604. X    call setgadget(SNAPHOST, 'PTCH', bool.patch)
  1605. X    signal loop
  1606. X
  1607. Xunderscore:
  1608. X    underscore = 1-underscore
  1609. X    call setgadget(SNAPHOST, 'USCR', bool.underscore)
  1610. X    signal loop
  1611. X
  1612. Xapply:
  1613. X    quitflag = 2
  1614. X    signal loop
  1615. X
  1616. X
  1617. Xdone:
  1618. Xcall ReadGadget(SNAPHOST, 'PREP')
  1619. Xcall waitpkt(SNAPPORT)
  1620. Xgetprep:
  1621. Xp = getpkt(SNAPPORT)
  1622. Xif p == NULL() then signal getprep
  1623. X
  1624. Xcmd = getarg(p)
  1625. Xcall reply(p, 0)
  1626. Xparse var cmd . ' ' prepend
  1627. X
  1628. Xcall ReadGadget(SNAPHOST, 'APP')
  1629. Xcall waitpkt(SNAPPORT)
  1630. Xgetapp:
  1631. Xp = getpkt(SNAPPORT)
  1632. Xif p == NULL() then signal getapp
  1633. X
  1634. Xcmd = getarg(p)
  1635. Xcall reply(p, 0)
  1636. Xparse var cmd . ' ' append
  1637. X
  1638. Xif c2d(textqual)=0 then do
  1639. X    call ShowText("No text qualifier specified!")
  1640. X    signal main
  1641. Xend
  1642. Xelse if c2d(gfxqual)=0 then do
  1643. X    call ShowText("No graphics qualifier specified!")
  1644. X    signal main
  1645. Xend
  1646. X
  1647. Xunixargs = ""
  1648. Xamigaargs = ""
  1649. Xif pri~=51           then do
  1650. X    unixargs = unixargs "-p"pri
  1651. X    amigaargs = amigaargs "priority" pri
  1652. Xend
  1653. Xif textqual~='0040'x then do
  1654. X    unixargs = unixargs "-t"c2x(textqual)
  1655. X    amigaargs = amigaargs "textqual" c2x(textqual)
  1656. Xend
  1657. Xif gfxqual~='0080'x  then do
  1658. X    unixargs = unixargs "-g"c2x(gfxqual)
  1659. X    amigaargs = amigaargs "gfxqual" c2x(gfxqual)
  1660. Xend
  1661. Xif inskey.inskey~='I'   then do
  1662. X    unixargs = unixargs "-i"inscode.inskey
  1663. X    amigaargs = amigaargs "insertkey" inscode.inskey
  1664. Xend
  1665. Xif cwkey.cwkey~='W'   then do
  1666. X    unixargs = unixargs "-w"cwcode.cwkey
  1667. X    amigaargs = amigaargs "cwkey" cwcode.cwkey
  1668. Xend
  1669. Xif prepend~="> "     then do
  1670. X    unixargs = unixargs "-P" '"'||prepend||'"'
  1671. X    amigaargs = amigaargs "prepend" '"'||prepend||'"'
  1672. Xend
  1673. Xif append~=""        then do
  1674. X    unixargs = unixargs "-A" '"'append'"'
  1675. X    amigaargs = amigaargs "append" '"'append'"'
  1676. Xend
  1677. Xif cdelay~=0         then do
  1678. X    unixargs = unixargs "-c"cdelay
  1679. X    amigaargs = amigaargs "chardelay" cdelay
  1680. Xend
  1681. Xif ldelay~=0         then do
  1682. X    unixargs = unixargs "-l"ldelay
  1683. X    amigaargs = amigaargs "linedelay" ldelay
  1684. Xend
  1685. Xif pattern~='7777'x  then do
  1686. X    unixargs = unixargs "-a"c2x(pattern)
  1687. X    amigaargs = amigaargs "crawlptrn" c2x(pattern)
  1688. Xend
  1689. Xif xerox             then do
  1690. X    unixargs = unixargs "-x"
  1691. X    amigaargs = amigaargs "XEROX"
  1692. Xend
  1693. Xif patch             then do
  1694. X    unixargs = unixargs "-e"
  1695. X    amigaargs = amigaargs "EARLYPATCH"
  1696. Xend
  1697. Xif underscore        then do
  1698. X    unixargs = unixargs "-r"
  1699. X    amigaargs = amigaargs "TRUEUNDERSCORE"
  1700. Xend
  1701. Xif join              then do
  1702. X    unixargs = unixargs "-j"
  1703. X    amigaargs = amigaargs "JOINLONG"
  1704. Xend
  1705. Xif unit~=0           then do
  1706. X    unixargs = unixargs "-u"unit
  1707. X    amigaargs = amigaargs "startunit" unit
  1708. Xend
  1709. Xif planes~='00'x     then do
  1710. X    unixargs = unixargs "-b"c2x(planes)
  1711. X    amigaargs = amigaargs "planemask" c2x(planes)
  1712. Xend
  1713. X
  1714. Xsnapcmd = "snap"
  1715. X
  1716. Xif quitflag=1 then do
  1717. X    say snapcmd || unixargs
  1718. X    if amigaargs ~= unixargs then do
  1719. X        say "or"
  1720. X        say snapcmd || amigaargs
  1721. X    end
  1722. Xend
  1723. Xelse do
  1724. X    if ~exists("snap") & ~exists("c:snap") then do
  1725. X        snapcmd = GetFile(50, 50, "sys:", "", "Find Snap for me")
  1726. X        if word(statef(snapcmd),1) ~= 'FILE' then do
  1727. X            snapcmd = snapcmd'snap'
  1728. X        end
  1729. X    end
  1730. X    if exists(snapcmd) then do
  1731. X        address command snapcmd unixargs
  1732. X    end
  1733. X    else do
  1734. X        call ShowText("Snap not found.")
  1735. X        signal main
  1736. X    end
  1737. Xend
  1738. X
  1739. Xerror:
  1740. Xcall Stop(SNAPHOST)
  1741. Xexit
  1742. X
  1743. Xshowtext: procedure expose SNAPHOST
  1744. X
  1745. Xparse arg text
  1746. X
  1747. Xcall SetAPen(SNAPHOST, 0)
  1748. Xcall RectFill(SNAPHOST, 5, 15, 490, 35)
  1749. Xcall SetAPen(SNAPHOST, 1)
  1750. Xcall Move(SNAPHOST, 5, 30)
  1751. Xcall Text(SNAPHOST, text)
  1752. Xreturn
  1753. END_OF_FILE
  1754. if test 13368 -ne `wc -c <'startsnap.rexx'`; then
  1755.     echo shar: \"'startsnap.rexx'\" unpacked with wrong size!
  1756. fi
  1757. # end of 'startsnap.rexx'
  1758. fi
  1759. echo shar: End of archive 2 \(of 4\).
  1760. cp /dev/null ark2isdone
  1761. MISSING=""
  1762. for I in 1 2 3 4 ; do
  1763.     if test ! -f ark${I}isdone ; then
  1764.     MISSING="${MISSING} ${I}"
  1765.     fi
  1766. done
  1767. if test "${MISSING}" = "" ; then
  1768.     echo You have unpacked all 4 archives.
  1769.     rm -f ark[1-9]isdone
  1770. else
  1771.     echo You still need to unpack the following archives:
  1772.     echo "        " ${MISSING}
  1773. fi
  1774. ##  End of shell archive.
  1775. exit 0
  1776. -- 
  1777. Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
  1778. Mail comments to the moderator at <amiga-request@cs.odu.edu>.
  1779. Post requests for sources, and general dicussion to comp.sys.amiga.
  1780.